home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 15245 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.8 KB

  1. Path: news.th-darmstadt.de!news
  2. From: Enno Sandner <enno@intellektik.informatik.th-darmstadt.de>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: strstream destruction
  5. Date: Wed, 03 Apr 1996 16:44:33 +0200
  6. Organization: Fachbereich Informatik, TH Darmstadt
  7. Message-ID: <31628ED1.2781E494@intellektik.informatik.th-darmstadt.de>
  8. References: <315AD92C.726D@itd.ssb.com> <4jhgt0$17f@piper.logicon.com> <4joujt$72p@lib104.its.rpi.edu> <4jttdk$i6v@HOPPER.ACM.ORG>
  9. NNTP-Posting-Host: kitz.intellektik.informatik.th-darmstadt.de
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.01 (X11; I; SunOS 4.1.3 sun4m)
  14.  
  15. Ken Varn wrote:
  16. > ...
  17. >
  18. > Just curious about this as it indirecly applies to something that I am
  19. > wondering about.  If a_stream is declared globally or as a data member of a
  20. > class, and you were to perform this function with it, would its internal
  21. > buffer get dynamically reallocated on each call, or would the object maintain
  22. > its own internal buffer and increase or decrease its size as needed (see
  23. > below)?
  24. > ostrstream a_stream;
  25. > String StrStrFunc ( void )      // some function using strstream
  26. > {
  27. >         String  a_string ;      // a 'string' class (char *)
  28. >         a_stream << a_variable  // any type
  29. >                  << ends ;      // null terminate string
  30. >         a_string = a_stream.str() ; // get the buffer
  31. >         a_stream.freeze(0) ;    // unfreeze buffer
  32. >         return ( a_string ) ;   // out of scope, deletes string
  33. >                                 // returns copy
  34. > }
  35.  
  36. According to the DWP the buffer is only destructed when the
  37. appropriate 'ostrstream' instance goes out of scope.
  38. 'freeze(0)' only marks the buffer as 'destroyable' but doesn't
  39. destroy it. Therefore only the 'frozen' flag is toggled in the
  40. given example.
  41.  
  42.     Enno
  43.